package com.example.boot3new.endpoint;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.HealthIndicator;
import org.springframework.stereotype.Component;

/**
 *
 * 自定义HealthEndpoint
 * @author lhq
 * @date 2023/05/30 20:29
 */
@Component
public class MyHealthEndpoint implements HealthIndicator {

    private Logger logger = LoggerFactory.getLogger(MyHealthEndpoint.class);
    @Override
    public Health health() {

//        int errorCode = check();
        logger.info("执行了自定义health endpoint");

        Health build = Health.down()
                .withDetail("msg", "error service")
                .withDetail("code", "500")
                .withException(new RuntimeException())
                .build();

//        return Health.up().build();
        return build;
    }
}
